package com.itheima.appserver.service;

import com.itheima.appserver.interceptor.UserHandler;
import com.itheima.dubbo.api.UserApi;
import com.itheima.model.domain.User;
import com.itheima.model.vo.HuanXinUserVo;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
public class HuanXinService {
    @DubboReference
    private UserApi userApi;

    public HuanXinUserVo findHxUser() {
        //获取当前用户id
        Long userId = UserHandler.getId();
        //查询用户
        User user = userApi.findById(userId);
        //判断用户是否存在
        if (user == null) {
            return null;
        }
        return new HuanXinUserVo(user.getHxUser(), user.getHxPassword());
    }
}
